{include file="public/header" /}
<!--main content start-->
<section class="main-content-wrapper">
    <section id="main-content">
        <div class="row">
    <div class="col-md-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">代理列表</h3>
            </div>
            <div class="panel-body">
                <form action="/admin/agent/index" method="get" enctype="multipart/form-data">
                <div class="row" style="margin-bottom: 20px;">
                    <div class="col-md-2">
                        <select class="form-control input-sm" id="search_type" name="level_id">
                            <option value="">代理级别</option>
                            {volist name="c_lists" id="vo"}
                            <option value="{$vo.id}" {if condition="$Request.get.level_id eq $vo.id"}selected {/if} >{$vo.title}</option>
                            {/volist}
                        </select>
                    </div>
                    <div class="col-md-3" style="padding-left: 0;">
                        <input type="text" class="form-control " placeholder="代理姓名" value="{if condition="!empty($Request.get.name)"}{$Request.get.name}{/if}" name="name">
                    </div>
                    <input type="submit" class="btn btn-primary" style="float: right;margin-right: 2%;" value="搜索">
                </div>
                </form>
                <div class="table-responsive">
                    <table class="table table-bordered ">
                        <thead>
                        <tr>
                            <th><input class="check" type="checkbox" id="all"></th>
                            <th>代理姓名</th>
                            <th>级别</th>
                            <th>手机号</th>
                            <th>微信</th>
                            <th>查询数量</th>
                            <th>到期时间</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="lists" id="vo"}
                        <tr class="bg_focuse">
                            <td><input class="check" type="checkbox" name="checkbox" value="{$Think.config.url}.html">{$vo.id}</td>
                            <td><a href="{$Think.config.url}" target="_blank">{$vo.name}</a> </td>
                            <!--<td>{$vo.name}</td>-->
                            <td>{$vo.title}</td>
                            <td>{$vo.phone}</td>
                            <td>{$vo.weixin}</td>
                            <td>{$vo.view}</td>
                            <td>{$vo.e_time|date="Y-m-d H:i",###}</td>
                            <td>
                                {if condition="($vo.status == 1)"}
                                <button type="button" class="btn btn-success" onclick="status({if condition="($vo.status == 1)"}2{else /}1{/if},{$vo.id})">正常</button>
                                {else /}
                                <button type="button" class="btn btn-warning" onclick="status({if condition="($vo.status == 1)"}2{else /}1{/if},{$vo.id})">冻结</button> {/if}
                            </td>
                            <td>
                                <button type="button" class="btn btn-xs btn-default" onclick="operation('detail',{$vo.id})">修改</button> &nbsp;
                                <button type="button" class="btn btn-xs btn-default" data-toggle="modal" data-target="#delete" onclick="operation('delete',{$vo.id})" >删除</button> &nbsp;
                                <button type="button" class="btn btn-xs btn-default" onclick="tuisong('{$Think.config.url}.html')">百度推送</button>
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                    <dt>
                        <!--<button class="btn btn-primary" id="getValue">推送选中的代理(帮助收录)</button>-->
                    </dt>
                </div>
                {$lists->render()}
            </div>
        </div>
    </div>
</div>
    </section>
</section>

<style>
    .table-striped>tbody>tr:nth-child(odd)>td:hover{
         background-color: #fff;
    }
    .bg_focuse:hover td{background-color: #dff0d8;}

</style>
<script language="javascript" type="text/javascript">
    function operation(type,id){
        if(type=='delete'){
            if(confirm("确定删除?")) {
                del(id);
            }
        }
        if(type=='detail'){
            window.location.href="/admin/agent/detail?id="+id;
        }
    }
    function del(id){
        $.ajax({
            type: "GET",  //提交方式
            url: "/admin/agent/agent_delete",//路径
            data: 'id='+id,
            dataType: "json",
            success: function (data) {
                if(data.status==0){
                    location.reload();
                }else{
                    alert('系统错误!');
                }
            }
        });
    }
    function status(next_status,id){
        $.ajax({
            type: "GET",  //提交方式
            url: "/admin/agent/agent_status",//路径
            data: {'id':id,'status':next_status},
            dataType: "json",
            success: function (data) {
                if(data.status==0){
                    location.reload();
                }
                if(data.status==2){
                    alert('系统错误，请刷新页面!');
                }
                if(data.status==3){
                    alert(data.msg);
                }
            }
        });
    }
    function tuisong(url){
        $.ajax({
            type: "POST",  //提交方式
            url: "/admin/seo/baidu_tuisong",//路径
            data: 'url='+url,
            dataType: "json",
            success: function (data) {
                if(data.status==0){
                    alert('推送成功')
                }else{
                    alert(data.msg);
                }
            }
        });
    }

    $(function () {
        //全选或全不选
        $("#all").click(function(){
            if(this.checked){
                $(".check").prop("checked", true);
            }else{
                $(".check").prop("checked", false);
            }
        });

        //获取选中选项的值
        $("#getValue").click(function(){
            var chk_value =[];
            $('input[name="checkbox"]:checked').each(function(){
                chk_value.push($(this).val());
            });
            if(chk_value.length==0){
                alert('你还没有选择任何内容！');
                return;
            }else{
                tuisong(chk_value,1);
            }
        });
    });
</script>

<style>
    /*时间插件*/
    .add-on{display:inline-block;width:auto;height:40px;min-width:16px;padding:4px 5px;font-size:14px;font-weight:normal;line-height:32px;text-align:center;text-shadow:0 1px 0 #fff;background-color:#eee;border:1px solid #ccc}
    .input-prepend .add-on:first-child{-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}
    .input-append .add-on{margin-left: -4px;}
    .input-append .add-on:last-child{margin-left:-4px;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}
    [class^="icon-"],[class*=" icon-"]{display:inline-block;width:14px;height:14px;margin-top:1px;*margin-right:.3em;line-height:14px;vertical-align:text-top;background-image:url("http://cdn.bootcss.com/twitter-bootstrap/2.2.2/img/glyphicons-halflings.png");background-position:14px 14px;background-repeat:no-repeat}
    .icon-th{background-position:-240px 0}
    .icon-remove{background-position:-312px 0}
    @media screen and (max-width: 850px) {
        .add-on {
            display: table-cell
        }
    }

</style>

<!--时间插件-->
<script src="/web_admin/js/bootstrap-datetimepicker.min.js"></script>
<link href="/web_admin/css/datetimepicker.css" rel='stylesheet' type='text/css' />


<script>
    $(".form_datetime4").datetimepicker({
        format: "yyyy-mm-dd hh:ii",
        autoclose: true,
        todayBtn: true
    });
</script>
<!--main content end-->
{include file="public/footer" /}